package com.py.admin.controller;

import com.py.model.admin.dtos.ChannelDto;
import com.py.model.common.dtos.ResponseResult;
import com.py.model.wemedia.pojos.WmChannel;
import org.springframework.web.bind.annotation.*;
import com.py.admin.service.AdChannelLabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 频道标签信息表 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelLabelController {

    @Autowired
    private AdChannelLabelService channelLabelService;



    /**
     * 新增频道
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {

       return channelLabelService.saveChannel(wmChannel);
    }


    /**
     * @param id
     */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {

        channelLabelService.deleteChannel(id);
        return ResponseResult.okResult(null);
    }


    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody ChannelDto dto){
        ResponseResult result = channelLabelService.findAll(dto);
        return result;
    }


    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        channelLabelService.updateByName(wmChannel);
        return ResponseResult.okResult(null);
    }

}
